/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufrgs.inf.inf05005.utils;

/**
 *
 * @author fkrahe
 */
public class Utils {
    // /Users/fkrahe/Desktop/basquete3.txt
    // colocar AQUI faz com que seja exibida a interface gráfica e o(s) botão(ões).
    public static final boolean DEBUG = false;
    public static final String LABEL_BUTTON_LOAD_FILE = "Carregar arquivo";
    public static final int WINDOW_WIDTH = 300;
    public static final int WINDOW_HEIGHT = 300;
//    public static final String PATTERN_AUTOMATON_DEF = "(\\S+)=\\(\\{(\\S+)+\\},\\{(\\S+)+\\},(\\S+){1},\\{(\\S+)+\\}\\)";
    public static final String PATTERN_AUTOMATON_DEF = "\\w+=\\(\\{(\\S+)\\},\\{(\\S+)\\},(\\S+){1},\\{(\\S+)\\}\\)";
    public static final String PATTERN_STATES = "\\w+(,(\\w+))*";
    public static final String PATTERN_STATE = "\\w+";
    public static final String PATTERN_ALFABET = ".(,.)*";
    public static final String PATTERN_SEPARATOR = ",";
    public static final String PATTERN_TRANSITION = "\\((\\S+)+,(.)\\)=(\\S+)";
    public static final String PATTERN_SEPARATOR_NEW = "@";
    public static final String SIMBOL_EMPTY = "null";

    /**
     * Apenas imprime a tabela de transições no console, para DEBUG
     * @param matrix 
     */
    public static void printMatrix(String[][] matrix) {
        // linha e coluna vem codificadas em matrix[0][0]
        String[] lico = matrix[0][0].split(",");
        int li = Integer.parseInt(lico[0]);
        int co = Integer.parseInt(lico[1]);
        // imprime a matriz
        System.out.println("");
        System.out.println("A matriz é:");
        for (int i = 0; i < li; i++) {
            for (int j = 0; j < co; j++) {
                if (matrix[i][j] == null) {
                    if (j + 1 == co) {
                        System.out.println(" " + Utils.SIMBOL_EMPTY + " ");
                    } else {
                        System.out.print(" " + Utils.SIMBOL_EMPTY + " ");
                    }
                } else {
                    if (j + 1 == co) {
                        System.out.println(" " + matrix[i][j] + " ");
                    } else {
                        System.out.print(" " + matrix[i][j] + " ");
                    }
                }
            }
        }
        System.out.println("");
    }

    public static void printArray(String[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]);
            if (i < array.length - 1) {
                System.out.print(", ");
            } else {
                System.out.println(".");
            }
        }
    }
}
